﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using personalplaner.business.dienstplan;
using personalplaner.business.dienstplan.plancollection;
using personalplaner.business.enums;
using personalplaner.business.extensions;
using personalplaner.business.stamm;
using personalplaner.common;
using personalplaner.common.mvvm;
using personalplaner.common.mvvm.commands;
using personalplaner.common.mvvm.mediator;
using personalplaner.common.plugins;
using personalplaner.gui.common;
using personalplaner.gui.plugins.dienstplan.views;
using personalplaner.gui.stamm.views;
using personalplaner.servicemodel.common;
using personalplaner.servicemodel.dataaccess;
using personalplaner.business;
using System.Text;



namespace personalplaner.gui.plugins.dienstplan.viewmodels
{
    public class DienstPlanViewModel : BaseViewModel
    {
		public DienstPlanViewModel(DependencyObject parent)
            : base(parent)
        {
        }

		#region Implementation

		[MediatorMessageSink("ReloadPlan", ParameterType = typeof(int))]
		public void ReloadPlan(int schemaid)
		{
			if (schemaid != SchemaId)
				return;

			// just reset the planid and all will be reinitialized
			PlanId = PlanId;
		}

		[MediatorMessageSink("RefreshPersonSaldo", ParameterType = typeof(SaldoAnpassung))]
		public void RefreshPersonSaldo(SaldoAnpassung saldoanpassung)
		{
			if (saldoanpassung == null)
				return;

			if (saldoanpassung.PlanId != PlanId)
				return;

			var da = GetService<IPlanDataAccess>();
			var itms = from r in Collection where r is PersonRow && r.AbteilungId == saldoanpassung.AbteilungId && r.ID == saldoanpassung.PrsId select r;
			foreach (var itm in itms)
			{
				var saldo = da.GetSaldo(itm.ID, itm.AbteilungId, PlanId);
				itm.Vortrag = saldo.Vortrag;
				itm.Soll = saldo.Soll;
				itm.Haben = saldo.Haben;
				itm.Anpassung = saldo.Anpassung;
			}
		}

    	public override void Loaded()
		{
			// reset the beleg history
			RaisePropertyChanged("ShowPensumInPlan");

			var mw = GetService<IMainWindowDisplayContainer>();
            mw.IsWaitVisible = false;
		}

    	private void InitializePlan(int planId)
        {
			var pda = GetService<IPersonDataAccess>();
            var da = GetService<IPlanDataAccess>();
			var plan = da.GetArbeitsPlan(planId);

            SchemaId = plan.SchemaId;

			//Name = plan.Name;
			//Von = plan.Von;
			//Bis = plan.Bis;
			//Schema = da.GetSchemaName(plan.SchemaId);

			var options = GetService<IOptionsDataAccess>();
			bool showDaysInPlan = options.ShowDaysInPlan;
			bool colorweekend = options.ColorWeekendInPlan;

			// set the default colors for the dienst overviews
            DienstOverviewItem.DienstCountEnoughColor = options.DienstCountEnoughColor;
            DienstOverviewItem.DienstCountMinusColor = options.DienstCountMinusColor;
            DienstOverviewItem.DienstCountPlusColor = options.DienstCountPlusColor;
			PersonRow.HolidayColor = options.HolidayColor;
			
			
			var headers = da.GetPlanRowHeaders(planId);
			//var rows = new ObservableCollection<IDienstPlanRow>();

			var rows = new DienstPlanCollection
			{
				Name = plan.Name,
				Von = plan.Von,
				Bis = plan.Bis,
				Schema = da.GetSchemaName(plan.SchemaId),
				PlanId = PlanId
			};




            foreach (var itm in headers)
            {
                IDienstPlanRow row = null;

                if (itm.PrsId < 0)
                {
                    row = new EmptyRow
                    {
                        Name = itm.Name,
                        //ID = itm.ID,
                        //PlanSchemaId = itm.PrsSchemaId,
                    };
                }
                else if (itm.PrsId == 0)
                {
					// add a row containing the days prior to the abteilung row
					if (showDaysInPlan)
					{
						var hr = new DayHeaderRow
						{
							//Name = itm.Name,
							ID = -2,
							RowColor = Colors.Gainsboro,
							HeaderColor = Colors.Gainsboro,
							PlanSchemaId = 0,
							AbteilungId = itm.AbteilungId,
							//Abteilung = itm.AbteilungeName,
						};

						hr.Initialize(plan.Von);
						rows.Add(hr);
					}




                	row = new AbteilungRow
                    {
                        Name = itm.Name,
                        ID = itm.PrsId,
                        //Color = itm.Color != null ? (Color)itm.Color : Colors.Transparent,
                        //PlanSchemaId = itm.PrsSchemaId,
                    };
                }
                else
                {
					var saldo = da.GetSaldo(itm.PrsId, itm.AbteilungId, planId);

					row = new PersonRow
					{
						Vorname = itm.Name,
						Nachname = itm.Nachname,
                        ID = itm.PrsId,
						Pensum = itm.Pensum,

						Vortrag = saldo.Vortrag,
						Soll = saldo.Soll,
						Haben = saldo.Haben,
						Anpassung = saldo.Anpassung
					};

                    switch (options.NameDisplayOption)
                    {
                        case enNameDisplay.VornameName:
                            row.Name = string.Format("{0} {1}", itm.Name, itm.Nachname);
                            break;
                        case enNameDisplay.NameVorname:
                            row.Name = string.Format("{0} {1}", itm.Nachname, itm.Name);
                            break;
                        case enNameDisplay.NameV:
                            row.Name = string.Format("{0} {1}.", itm.Nachname, itm.Name.Substring(0,1));
                            break;
                        case enNameDisplay.Name:
                            row.Name = itm.Nachname;
                            break;
                    }
                }

                row.RowColor = itm.Color != null ? (Color)itm.Color : Colors.Transparent;
				row.HeaderColor = itm.Color != null ? (Color)itm.Color : Colors.Gainsboro;
                row.PlanSchemaId = itm.PrsSchemaId;
                row.AbteilungId = itm.AbteilungId;
                row.Abteilung = itm.AbteilungeName;

                List<PlanItem> lst = null;

                var r = row as PersonRow;
                if (r != null)
                {
                    lst = da.GetPlanRow(planId, itm.PrsSchemaId, itm.PrsId).ToList();
                }
                row.Initialize(plan.Von, lst);

				if (row is PersonRow || row is EmptyRow)
				{
					if (row is PersonRow)
					{
						// set the backgroundcolor to holiday color
						var holidays = pda.GetHolidays(row.ID, plan.Von.Year, plan.Von.Month);
						if (holidays != null)
						{
							foreach (var holiday in holidays)
							{
								int begin = holiday.Von.Day;
								if (holiday.Von.Month != plan.Von.Month)
									begin = 1;
								int end = holiday.Bis.Day;
								if (holiday.Bis.Month != plan.Von.Month)
									end = DateTime.DaysInMonth(plan.Von.Year, plan.Von.Month);

								while (begin <= end)
								{
									var pi = (from planitm in row
											  where planitm.Datum.Day == begin
											  select planitm).FirstOrDefault();
									begin++;
									if (pi == null)
										continue;

									pi.BackgroundColor = PersonRow.HolidayColor;
									pi.IsHoliday = true;
								}
							}
						}
					}

					if (colorweekend)
						foreach (var pi in row)
							SetWeekendColor(pi);
				}

            	rows.Add(row);
            }



			var dda = GetService<IDiensteDataAccess>();
			var tmp =  dda.GetPlanDienstOverview(da.GetSchemaId(planId));
			if (tmp == null)
				return;

			var dov = new ObservableCollection<DienstOverviewRow>(tmp);
			foreach (var itm in dov)
			{
				itm.HeaderColor = Colors.Gainsboro;
				itm.Initialize(plan.Von);

                for (int i = 0; i < rows[0].Count; i++)
                {
                    int cnt = 0;
					foreach (var dc in rows)
                    {
                        if (dc[i].DienstId == itm.DienstId)
                            cnt++;
                    }
                    itm[i].DienstCount = cnt;
                }
			}

            DienstOverviewRows = dov;

			Collection = rows;
        }

        private void SetWeekendColor(PlanItem item)
        {
            //if (item.Color != Colors.Transparent && item.Color != Colors.White)
            if ((item.Color != null && !((Color)item.Color).IsEmptyColor()) || item.IsHoliday)
                return;

            var da = GetService<IOptionsDataAccess>();

            if (item.Datum.DayOfWeek == DayOfWeek.Saturday)
            {
                item.Color = da.SaturdayColor;
            }
            else if (item.Datum.DayOfWeek == DayOfWeek.Sunday)
            {
                item.Color = da.SundayColor;
            }

            if (IsDayFeiertag(item.Datum))
            {
                item.Color = da.SundayColor;
            }
        }

        private bool IsDayFeiertag(DateTime dateTime)
        {
            if (Feiertage == null)
                return false;

            var itms = from a in Feiertage where a.Von == dateTime select a;

            return itms.Any();
        }

		#endregion

		#region Menu

		#region Main

		ICommand _refreshplancommand;
		public ICommand RefreshPlanCommand
		{
			get
			{
				if (_refreshplancommand == null)
					_refreshplancommand = new RelayCommand(OnRefreshPlan);
				return _refreshplancommand;
			}
		}

		private void OnRefreshPlan(object param)
		{
			// just reset the planid and all will be reinitialized
			PlanId = PlanId;
		}

        ICommand _closeplancommand;
        public ICommand ClosePlanCommand
        {
            get
            {
                if (_closeplancommand == null)
                    _closeplancommand = new RelayCommand(OnClosePlan);
                return _closeplancommand;
            }
        }

        private void OnClosePlan(object param)
        {
            // use mediator to notify all suscribed methods that a plan has to be closed
            Mediator.NotifyColleagues<int>("ClosePlan", PlanId);
        }

		#endregion

        #region Bearbeiten

        ICommand _editSchemaCommand;
		public ICommand EditSchemaCommand
		{
			get
			{
                if (_editSchemaCommand == null)
                    _editSchemaCommand = new RelayCommand(OnEditSchema);
                return _editSchemaCommand;
			}
		}

        private void OnEditSchema(object param)
        {
            var itm = new PlanLayoutStamm();
            itm.SetSinglePlanSchema(SchemaId);

            var service = GetService<IMainWindowDisplayContainer>();
            service.AddSimpleContentItem(enDisplayItemType.PlanLayoutStamm, itm, true);
        }

		ICommand _editSaldoCommand;
		public ICommand EditSaldoCommand
		{
			get
			{
				if (_editSaldoCommand == null)
					_editSaldoCommand = new RelayCommand(OnEditSaldo);
				return _editSaldoCommand;
			}
		}

		private void OnEditSaldo(object param)
		{
			var service = GetService<IMainWindowDisplayContainer>();
			service.IsWaitVisible = true;

			var itm = new EditSaldoView()
			{
                PlanId = PlanId,
				SchemaId = SchemaId
			};

			service.AddSimpleContentItem(enDisplayItemType.EditSaldo, itm, true);
		}

        #endregion

        #region Print

        ICommand _printCommand;
		public ICommand PrintCommand
		{
			get
			{
				if (_printCommand == null)
					_printCommand = new RelayCommand(OnPrint);
				return _printCommand;
			}
		}

		private void OnPrint(object param)
		{
			var collection = Collection as DienstPlanCollection;
			if (collection == null)
				return;

			var mw = GetService<IMainWindowDisplayContainer>();
            mw.IsWaitVisible = true;


			//var bw = new System.ComponentModel.BackgroundWorker();
			//bw.DoWork += (s, a) =>
			//{
			//    var pv = new PrintView(collection);
			//    //SetPrintView(pv);
			//    Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { SetPrintView(pv); }, null);
			//};

			//bw.RunWorkerAsync();


            // create a copy of the collection
            //var collectionClone = new DienstPlanCollection();
            var collectionClone = collection.Clone();
            foreach (var itm in collection)
            {
                IDienstPlanRow row = null;
                if (itm is DayHeaderRow)
                {
                    row = ((DayHeaderRow)itm).Clone();
                }
                else if (itm is EmptyRow)
                {
                    row = ((EmptyRow)itm).Clone();
                }
                else if (itm is AbteilungRow)
                {
                    row = ((AbteilungRow)itm).Clone();
                }
                else if (itm is PersonRow)
                {
                    row = ((PersonRow)itm).Clone();
                }
                else if (itm is SimpleRow)
                {
                    row = ((SimpleRow)itm).Clone();
                }
                else if (itm is OverviewRow)
                {
                    row = ((OverviewRow)itm).Clone();
                }
                else
                {
                    ServiceLocator.GetService<IErrorLoger>().LoggMessage(enMessageType.ERROR, string.Format("{0} is not of any known type in DienstPlanViewModel.OnPrint",itm.ToString()));
                    MessageBox.Show("Beim erstellen der Druckansicht ist ein Fehler aufgetreten", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    continue;
                }

                foreach (var tmp in itm)
                    row.Add(tmp.Clone());

                collectionClone.Add(row);
            }

			var service = GetService<IMainWindowDisplayContainer>();
            //service.AddSimpleContentItem(enDisplayItemType.PrintView, new PrintView(collection), true);
            service.AddSimpleContentItem(enDisplayItemType.PrintView, new PrintView(collectionClone), true);
		}

		//private void SetPrintView(PrintView pv)
		//{
		//    var service = GetService<IMainWindowDisplayContainer>();
		//    service.AddSimpleContentItem(enDisplayItemType.PrintView, pv, true);
		//}

    	#endregion

        #region Extras

        ICommand _planautomationCommand;
        public ICommand PlanAutomationCommand
        {
            get
            {
                if (_planautomationCommand == null)
                    _planautomationCommand = new RelayCommand(OnPlanAutomation);
                return _planautomationCommand;
            }
        }

        private void OnPlanAutomation(object param)
        {
            var mw = GetService<IMainWindowDisplayContainer>();
            mw.IsWaitVisible = true;

            var da = GetService<IPlanDataAccess>();
            try
            {
                var pa = new PlanAutomation(SettingsProvider.Settings);
                pa.ScedulePlan(da.GetArbeitsPlan(PlanId));
            }
            catch (Exception e)
            {
                var sb = new StringBuilder();
                sb.AppendLine(personalplaner.gui.Properties.Resources.FehlerBeimZuweisenDienste);
                sb.AppendLine();
                sb.AppendLine(e.Message);
                MessageBox.Show(sb.ToString(), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }

            // just reset the planid and all will be reinitialized
            PlanId = PlanId;

            mw.IsWaitVisible = false;
        }

        ICommand _deletePlanCommand;
        public ICommand DeletePlanCommand
        {
            get
            {
                if (_deletePlanCommand == null)
                    _deletePlanCommand = new RelayCommand(OnDeletePlan);
                return _deletePlanCommand;
            }
        }

        private void OnDeletePlan(object param)
        {
            if (MessageBox.Show(Window.GetWindow(Parent),
                personalplaner.gui.Properties.Resources.DeletePlanMessage,
                personalplaner.gui.Properties.Resources.Delete,
                MessageBoxButton.OKCancel,
                MessageBoxImage.Warning) == MessageBoxResult.OK)
            {
                GetService<IErrorLoger>().LoggMessage(enMessageType.USER_EVENT, string.Format("Delete plan {0} clicked", PlanId));
                var da = GetService<IPlanDataAccess>();
                da.DeletePlan(PlanId);

                var options = GetService<IOptionsDataAccess>();
                if (options.DeleteSchemaOnDeletePlan)
                {

                    var sda = GetService<IPlanSchemaDataAccess>();
                    var plaene = sda.GetPlaeneFromSchemaId(SchemaId);

                    // only delete the layout if only 1 plan was created with it
                    if (plaene != null && !plaene.Any())
                    {
                        if (sda.DeleteSchema(SchemaId) && options.ResetLastSchemaOnDeleteSchema)
                        {
                            var layouts = sda.GetSchemas(false);
                            if (layouts == null || !layouts.Any())
                            {
                                layouts = sda.GetSchemas(true);
                                if (layouts != null && layouts.Any())
                                {
                                    // reactivate a schema
                                    var schemaid = layouts.Max(l => l.SchemaID);
                                    sda.UpdateSchemaStatus(schemaid, true);
                                }
                            }
                        }
                        Mediator.NotifyColleagues<int>("SchemaDeleted", SchemaId);
                    }
                }

                // use mediator to notify all suscribed methods that a plan was deleted
                Mediator.NotifyColleagues<int>("PlanDeleted", PlanId);
            }
        }

        ICommand _planabschliessencommand;
        public ICommand PlanAbschliessenCommand
        {
            get
            {
                if (_planabschliessencommand == null)
                    _planabschliessencommand = new RelayCommand(OnPlanAbschliessen);
                return _planabschliessencommand;
            }
        }

        private void OnPlanAbschliessen(object param)
        {
            if (MessageBox.Show(Properties.Resources.ClosePlanMessage, Properties.Resources.ClosePlan, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                return;

            GetService<IErrorLoger>().LoggMessage(enMessageType.USER_EVENT, string.Format("Finish plan {0} clicked", PlanId));
            var da = GetService<IPlanDataAccess>();
            da.UpdatePlanStatus(PlanId, business.enums.enStatus.Inactive);

            // use mediator to notify all suscribed methods that a plan has to be removed
            Mediator.NotifyColleagues<int>("RemovePlan", PlanId);
        }


        ICommand _recalculatesaldoscommand;
        public ICommand RecalculateSaldosCommand
        {
            get
            {
                if (_recalculatesaldoscommand == null)
                    _recalculatesaldoscommand = new RelayCommand(OnRecalculateSaldos);
                return _recalculatesaldoscommand;
            }
        }

        private void OnRecalculateSaldos(object param)
        {
            var da = GetService<IPlanDataAccess>();

            var itms = from r in Collection where r is PersonRow /*&& r.AbteilungId == saldoanpassung.AbteilungId && r.ID == saldoanpassung.PrsId*/ select r;
            foreach (var itm in itms)
            {
                da.RecalculateSaldosInPlan(PlanId, itm.ID, itm.AbteilungId);

                var saldo = da.GetSaldo(itm.ID, itm.AbteilungId, PlanId);
                itm.Vortrag = saldo.Vortrag;
                itm.Soll = saldo.Soll;
                itm.Haben = saldo.Haben;
                itm.Anpassung = saldo.Anpassung;
            }
        }

        #endregion

        #endregion

        #region Commands

        ICommand _cellClickedCommand;
    	public ICommand CellClickedCommand
    	{
    		get
    		{
    			if (_cellClickedCommand == null)
    				_cellClickedCommand = new RelayCommand<PlanItem>(OnCellClicked, CanEcecuteCellClick);
    			return _cellClickedCommand;
    		}
    	}

        private void OnCellClicked(PlanItem parameter)
        {
            if (Controler == null)
                return;
            
            if (parameter.PrsId <= 0)
                return;

            Color? color = null;

            if (Controler.SelectedDienst != null)
            {
                // 1. set dienst
                parameter.DienstId = Controler.SelectedDienst.DienstID;
                parameter.Name = Controler.SelectedDienst.DienstName;
				parameter.DienstType = Controler.SelectedDienst.DienstType;
                color = Controler.SelectedDienst.Color;
            }

            if (!Controler.SelectedColor.IsEmptyColor())
                color = Controler.SelectedColor;

            // 2. set color
            parameter.Color = color;

            var da = GetService<IPlanDataAccess>();
            if (!da.SaveDienstInPlan(PlanId, parameter.PrsId, parameter.AbteilungId, parameter.Datum, parameter.DienstId))
                MessageBox.Show("Beim Speichern des Dienstes is ein Fehler aufgetreten.", "Fehler beim Speichern", MessageBoxButton.OK, MessageBoxImage.Error);

            if (!da.SaveColorInPlan(PlanId, parameter.PrsId, parameter.AbteilungId, parameter.Datum, parameter.Color))
                MessageBox.Show("Beim Speichern des Dienstes is ein Fehler aufgetreten.", "Fehler beim Speichern", MessageBoxButton.OK, MessageBoxImage.Error);

			// set the background color if it is a dienst of type holiday
			//parameter.BackgroundColor = parameter.DienstType == enDienstType.Ferien ? PersonRow.HolidayColor : null;
			parameter.BackgroundColor = parameter.DienstType == enDienstType.Ferien ? PersonRow.HolidayColor : parameter.IsHoliday ? PersonRow.HolidayColor : null;
            
            // 3. set weekend color
            SetWeekendColor(parameter);

			var row = (from a in Collection where a.ID == parameter.PrsId && a.AbteilungId == parameter.AbteilungId select a).First();
            if (row == null)
                return;

            // 4. recalculate the dienstoverview count
            var index = row.IndexOf(parameter);
            foreach(var or in DienstOverviewRows)
            {
                int cnt = 0;
				foreach (var dc in Collection)
                {
                    if (dc[index].DienstId == or.DienstId && dc[index].AbteilungId == or.AbteilungId)
                        cnt++;
                }
                or[index].DienstCount = cnt;
            }

            // 5. recalculate saldos
            var saldo = da.GetSaldo(parameter.PrsId, parameter.AbteilungId, PlanId);
            
            row.Vortrag = saldo.Vortrag;
            row.Soll = saldo.Soll;
            row.Haben = saldo.Haben;
            row.Anpassung = saldo.Anpassung;
        }

		private bool CanEcecuteCellClick(PlanItem parameter)
		{
			if (parameter == null)
				return false;

			return parameter.CanExecuteCommand;
		}

    	#endregion

		#region Properties

        IList<Feiertag> _feiertage;
        public IList<Feiertag> Feiertage
        {
            get
            {
                if (_feiertage == null)
                {
                    if (PlanId == 0)
                        return null;

                    var da = GetService<IPlanDataAccess>();
                    var lst = da.GetFeiertageInPlan(PlanId);
                    _feiertage = lst != null ? new List<Feiertag>(lst) : new List<Feiertag>();
                }
                return _feiertage;
            }
        }

		IDienstPlanControler _controler;
    	public IDienstPlanControler Controler
    	{
    		get
    		{
    			return _controler;
    		}
    		set
    		{
    			_controler = value;
				RaisePropertyChanged("Controler");
    		}
    	}

		int _planId;
		public int PlanId
		{
			get { return _planId; }
			set
			{
				_planId = value;
				RaisePropertyChanged("PlanId");

				InitializePlan(value);
			}
		}

        public int SchemaId
        {
            get;
            set;
        }

		//string _name;
		//public string Name
		//{
		//    get { return _name; }
		//    set
		//    {
		//        _name = value;
		//        RaisePropertyChanged("Name");
		//    }
		//}

		//DateTime _von;
		//public DateTime Von
		//{
		//    get { return _von; }
		//    set
		//    {
		//        _von = value;
		//        RaisePropertyChanged("Von");
		//    }
		//}

		//DateTime _bis;
		//public DateTime Bis
		//{
		//    get { return _bis; }
		//    set
		//    {
		//        _bis = value;
		//        RaisePropertyChanged("Bis");
		//    }
		//}

		//string _schema;
		//public string Schema
		//{
		//    get
		//    {
		//        return _schema;
		//    }
		//    set
		//    {
		//        _schema = value;
		//        RaisePropertyChanged("Schema");
		//    }
		//}
        
		//IList<IDienstPlanRow> _rows;
		//public IList<IDienstPlanRow> Rows
		//{
		//    get
		//    {
		//        return _rows;
		//    }
		//    set
		//    {
		//        _rows = value;
		//        RaisePropertyChanged("Rows");
		//    }
		//}

		//IList<IDienstPlanRow> _collection;
		//public IList<IDienstPlanRow> Collection
		//{
		//    get
		//    {
		//        return _collection;
		//    }
		//    set
		//    {
		//        _collection = value;
		//        RaisePropertyChanged("Collection");
		//    }
		//}
		DienstPlanCollection _collection;
		public DienstPlanCollection Collection
		{
			get
			{
				return _collection;
			}
			set
			{
				_collection = value;
				RaisePropertyChanged("Collection");
			}
		}

		IList<DienstOverviewRow> _dienstOverviewRows;
    	public IList<DienstOverviewRow> DienstOverviewRows
    	{
    		get
    		{
    			return _dienstOverviewRows;
    		}
    		set
    		{
    			_dienstOverviewRows = value;
    			RaisePropertyChanged("DienstOverviewRows");
    		}
    	}

    	public bool ShowPensumInPlan
		{
			get
			{
				var da = GetService<IOptionsDataAccess>();
				return da.ShowPensumInPlan;
			}
		}

    	#endregion
    }
}
